﻿using RaytracerLib.MathLib;
using YAXLib;

namespace RaytracerLib.Layers
{
    public class TransformOperationLayer : UnaryLayer
    {
        [YAXNode]
        public Matrix3 Transform { get; set; }

        public TransformOperationLayer(Layer a_childLayer, Matrix3 a_transform)
            : base(a_childLayer)
        {
            Transform = a_transform;
        }

        public override ColorFloat GetColor(Vector2 a_uv, Intersection a_intersection)
        {
            return ChildLayer.GetColor(Transform * a_uv, a_intersection);
        }

        public override double GetValue(Vector2 a_uv, Intersection a_intersection)
        {
            return ChildLayer.GetValue(Transform * a_uv, a_intersection);
        }

        public override Tangents GetTangents(Vector2 a_uv, Vector2 a_tx, Vector2 a_ty,
            Intersection a_intersection)
        {
            return ChildLayer.GetTangents(Transform * a_uv, Transform * a_tx,
                Transform * a_ty, a_intersection);
        }
    }
}